<%@ page pageEncoding="UTF-8"%>
<%@page import="com.utils.StringTool"%>
<%@page import="com.vinatech.util.*"%>
<%@page import="com.base.DatabaseObject"%>
<%@page import="java.math.BigDecimal"%>
<%@include file="inc-meta.jsp"%>
<html>
  <head>    
    <title>login</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  <body>
  <%
  try{
	String user = "";
	String pass = "";
	String id = "";
	user = request.getParameter("username");
	pass = request.getParameter("password");
	if(user == "" || pass == "")
	{
		session.putValue("id","-1");		
		response.sendRedirect("formLogin.jsp");
		System.out.print("id gan session"+id);
	
	}
	else
	{
		pass = MD5.toBase64(pass.getBytes());
		int intTest = contentDAO.testLogin(user,pass);
		id = Integer.toString(intTest);
		
		if(intTest == 0) //khong ton tai trong csdl
		{
  			session.putValue("id","0");		
			response.sendRedirect("formRegister.jsp");
			System.out.print("id gan session"+id);
		}
		else
		{
  			session.putValue("id",id);		
			response.sendRedirect("index.jsp");	
			System.out.print("id gan session"+id);
		}
	}}//end try
	catch (Exception e){
		session.putValue("id","-2");
	}
   %>
  </body>
</html>
